package com.pvdnc.outguess;

import android.app.Activity;
import android.content.Intent;

import androidx.annotation.Nullable;

import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

public class PickerManager {
    private static final PickerManager INSTANCE=new PickerManager();

    public static PickerManager getInstance(){
        return INSTANCE;
    }

    private final Map<String,FilePicker> mPickerMap=new ConcurrentHashMap<>();

    public void put(String name, Activity activity){
        mPickerMap.put(name,new FilePicker(activity));
    }

    public FilePicker get(String name){
        return Objects.requireNonNull(mPickerMap.get(name));
    }

    public void onActivityResult(int requestCode, int resultCode,@Nullable Intent data){
        for(FilePicker picker:mPickerMap.values()){
            picker.onActivityResult(requestCode, resultCode, data);
        }
    }
}
